#Packages required####
require(ggplot2)
require(readxl)
require(FactoMineR)
require(Factoshiny)
require(factoextra)
#PCA section 4.2, first part_Flakes####
#### Cleaning workspace and figure #
rm(list = ls()) # cleaning environment
graphics.off()  # cleaning PLOT
cat("\014")   # cleaning console
#### loading packages #
library(ggplot2) # for graphs
library(readxl) #for reading excel files
library(factoextra)
##### load dataset###
library(readxl)
Flakes <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/PCA/Flakes.xlsx")
View(Flakes)
# working on variables to convert in factors#
Flakes$RM<- as.factor(Flakes$RM)
### selecting the numerical variables to perform PCA on flakes###
# Raw materials (RM)were not considered as variables
Flk_PCA  = Flakes
Flk_PCA$RM<- NULL
Flk_PCA$ID <- NULL
# PCA#
group <- as.factor (Flakes$RM) #isolating RM as variables for raw materials
PCA = prcomp(Flk_PCA,scale. = TRUE) # to run PCA using the variables previously selected
fviz_pca_ind(PCA, # PCA
col.ind = group, # to colour groups
geom = "point",  # to visualize ID as points in the graph
palette = c("red", "black"),
addEllipses = TRUE, # creating the ellipses to cluster results
ellipse.type = "t",
legend.title = "Groups", # Legend
repel = TRUE) #avoiding the overlapping among geometries
fviz_eig(PCA)
get_pca_ind(PCA)
get_pca_var(PCA)
fviz_pca_ind(PCA)
fviz_pca_var(PCA)
fviz_pca_biplot(PCA)
get_eigenvalue(PCA)
fviz_eig(PCA)
#### loading packages #
library(ggplot2) # for graphs
library(readxl) #for reading excel files
library(factoextra) #for multivariate analyses
##### load dataset###
library(readxl)
Flakes <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/PCA/Flakes.xlsx")
View(Flakes)
# working on variables (Raw Material) to convert in factors#
Flakes$RM<- as.factor(Flakes$RM)
### selecting the numerical variables to perform PCA on flakes###
# Raw materials were not considered as variables
Flk_PCA  = Flakes
Flk_PCA$RM<- NULL
Flk_PCA$ID <- NULL
# PCA#
group <- as.factor (Flakes$RM) #isolating RM as variables for raw materials
PCA = prcomp(Flk_PCA,scale. = TRUE) # to run PCA using the variables previously selected
fviz_pca_ind(PCA, # PCA
col.ind = group, # to colour groups based on RM (Basalt and Quartz)
geom = "point",  # to visualize ID as points in the graph
palette = c("red", "black"),
addEllipses = TRUE, # creating the ellipses to cluster results
ellipse.type = "t",
legend.title = "Raw Materials", # Legend
repel = TRUE) #avoiding the overlapping among geometries
#### PCA on cores_section 4.2 second part ####
#cleaning workspace
rm(list = ls()) # cleaning environment environment
graphics.off()  # cleaning PLOT
cat("\014")   # Cleaning console
#### loading packages #
library(ggplot2)
library(readxl)
library(factoextra)
##### load data#
library(readxl)
Cores <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/PCA/Cores.xlsx")
View(Cores)
# Cleaning variables #
Cores$ï..ID <- NULL
Cores$NSP <- NULL
Cores$NTSP <- NULL
#working on variables to convert in factor
Cores$RM<- as.factor(Cores$RM)
Cor_PCA  = Cores
Cor_PCA$RM<-NULL
Cor_PCA$ID<-NULL
#PCA
group <- as.factor (Cores$RM)
PCA = prcomp(Cor_PCA, scale. = TRUE)
fviz_pca_ind(PCA, #PCA
col.ind = group, # Colouring points
geom = "point",  # visualizing ID as points
palette = c("blue", "red"), # colours of groups
addEllipses = TRUE, # creating ellipses to cluster results
ellipse.type = "t",
legend.title = "Raw Materials", # legend
repel = TRUE) # voiding the overlapping among geometries
#PCA
group <- as.factor (Cores$RM)
PCA = prcomp(Cor_PCA, scale. = TRUE)
fviz_pca_ind(PCA, #PCA
col.ind = group, # Colouring points
geom = "point",  # visualizing ID as points
palette = c("blue", "red"), # colours of groups
addEllipses = TRUE, # creating ellipses to cluster results
ellipse.type = "t",
legend.title = "Groups", # legend
repel = TRUE) # voiding the overlapping among geometries
##### load data#
library(readxl)
Cores <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/PCA/Cores.xlsx")
View(Cores)
# Cleaning variables #
Cores$ï..ID <- NULL
Cores$NSP <- NULL
Cores$NTSP <- NULL
Cores$FR <- NULL
#working on variables to convert in factor
Cores$RM<- as.factor(Cores$RM)
#working on variables to convert in factor
Cores$RM<- as.factor(Cores$RM)
Cor_PCA  = Cores
Cor_PCA$RM<-NULL
Cor_PCA$ID<-NULL
#PCA
group <- as.factor (Cores$RM)
PCA = prcomp(Cor_PCA, scale. = TRUE)
fviz_pca_ind(PCA, #PCA
col.ind = group, # Colouring points
geom = "point",  # visualizing ID as points
palette = c("blue", "red"), # colours of groups
addEllipses = TRUE, # creating ellipses to cluster results
ellipse.type = "t",
legend.title = "Groups", # legend
repel = TRUE) # voiding the overlapping among geometries
fviz_pca_ind(PCA, #PCA
col.ind = group, # Colouring points
geom = "point",  # visualizing ID as points
palette = c("blue", "red"), # colours of groups
addEllipses = TRUE, # creating ellipses to cluster results
ellipse.type = "t",
legend.title = "Raw Materials", # legend
repel = TRUE) # voiding the overlapping among geometries
#Correspondence analysis, section 4.2 last part####
#cleaning workspace
rm(list = ls()) # cleaning environment environment
graphics.off()  # cleaning PLOT
cat("\014")   # Cleaning console
library(FactoMineR)
library(Factoshiny)
#CA for flakes####
#import dataser_Flakes_Quali to explore categorical variables
library(readxl)
Flakes_Quali2 <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/CA/Flakes_Quali2.xlsx")
View(Flakes_Quali2)
summary(Flakes_Quali2)#to show variables
str(Flakes_Quali2)
library(Factoshiny)
CA <-Factoshiny(Flakes_Quali2)
res.CA<-CA(Flakes_Quali2,quali.sup=c(1),graph=FALSE)
plot.CA(res.CA,selectRow='cos2 0',unselect=0,cex=0.75,cex.main=0.75,cex.axis=0.75,title="CA flake analysis",col.row='#000003',col.quali.sup='#0009FF')
CA <-Factoshiny(Flakes_Quali2)
#To create plot for Figure 13 and 14
plot.CA(res.CA,selectRow='cos2 0',unselect=0,cex=0.75,cex.main=0.75,cex.axis=0.75,title="CA flake analysis",col.row='#000003',col.quali.sup='#0009FF')
#Packages required####
require(ggplot2)
require(readxl)
require(FactoMineR)
require(Factoshiny)
require(factoextra)
graphics.off()  # cleaning PLOT
cat("\014")   # Cleaning console
library(FactoMineR)
library(Factoshiny)
#Correspondence analysis, section 4.2 last part####
#cleaning workspace
rm(list = ls()) # cleaning environment environment
#importa Dataset Core_quali2 to explore categorical variables
library(readxl)
Core_quali2 <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawDataFusco et al/Database_Raw/CA/Core_quali2.xlsx")
#importa Dataset Core_quali2 to explore categorical variables
library(readxl)
Core_quali2 <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawData_Update_Fusco et al/Database_Raw/CA/Core_quali2.xlsx")
View(Core_quali2)
summary(Core_quali2)#to show variables
library(Factoshiny)
CA2 <-Factoshiny(Core_quali2)
View(Core_quali2)
#importa Dataset Core_quali2 to explore categorical variables
library(readxl)
Core_quali2 <- read_excel("C:/Users/Flavio/Desktop/submission luglio 2021_JLS/RawData_Update_Fusco et al/Database_Raw/CA/Core_quali2.xlsx")
View(Core_quali2)
summary(Core_quali2)#to show variables
library(Factoshiny)
CA2 <-Factoshiny(Core_quali2)
